package com.ihr360.payroll.service.salarytasklet.step.writer;


import com.ihr360.commons.lang.CollectionUtils;
import com.ihr360.job.core.item.ItemWriter;
import com.ihr360.payroll.dao.MergeReportStaffSalaryRepository;
import com.ihr360.payroll.model.dto.salary.report.MergeReportStaffSalary;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 合并计税，输出报表结果
 * @author davidwei
 */
@Component
public class MergeTaxSalaryReportDataWriter implements ItemWriter<List<MergeReportStaffSalary>> {
    @Autowired
    private MergeReportStaffSalaryRepository mergeReportStaffSalaryRepository;

    @Override
    public void write(List<? extends List<MergeReportStaffSalary>> items) throws Exception {
        if (CollectionUtils.isNotEmpty(items)) {
            List<MergeReportStaffSalary> reportStaffSalaries = items.get(0);
            mergeReportStaffSalaryRepository.save(reportStaffSalaries);
        }
    }
}